package cn.xyinping.pay.dto;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

/**
 * @author 27266
 * @desrciption 支付宝参数配置，由支付宝开放平台提供
 * @date 2021/11/9
 */
@Data
public class AlipayDto {
    // 等待用户付款付款
    public static final String WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
    // 未支付交易超时关闭
    public static final String TRADE_CLOSED = "TRADE_CLOSED";
    // 支付成功
    public static final String TRADE_SUCCESS = "TRADE_SUCCESS";
    // 交易结束，不能再退款
    public static final String TRADE_FINISHED = "TRADE_FINISHED";

    private String charset;
    private String gmt_create;
    private String gmt_payment;
    private String notify_time;
    private String subject;
    private String sign;
    private String buyer_id;
    private String invoice_amount;
    private String version;
    private String notify_id;
    private String fund_bill_list;
    private String notify_type;
    private String out_trade_no;
    private String total_amount;
    //交易状态  抽常量
    private String trade_status;
    private String trade_no;
    private String auth_app_id;
    private String receipt_amount;
    private String point_amount;
    private String app_id;
    private String buyer_pay_amount;
    private String sign_type;
    private String seller_id;
    private String code;
    private String msg;

    // 交易是否成功
    @JSONField(serialize = false)
    public boolean isTradeSuccess() {
        return this.trade_status.equals(TRADE_SUCCESS)
                || this.trade_status.equals(TRADE_FINISHED);
    }

    //支付中
    @JSONField(serialize = false)
    public boolean isTradeWit() {
        return this.trade_status.equals(WAIT_BUYER_PAY);
    }

    //未付款交易超时关闭，或支付完成后全额退款。
    @JSONField(serialize = false)
    public boolean isTradeExpire() {
        return this.trade_status.equals(TRADE_CLOSED);
    }
}
